home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / trig / trig.bas < prev    next >
BASIC Source File  |  1995-05-09  |  3KB  |  133 lines

  1. 'This Module was prepared by
  2. '   Robert J. Gorman Jr.
  3. '   NATURESOFT
  4. '
  5. 'and may be used free of charge to develop applications.
  6.  
  7. 'All that I ask it that if you distribute this file please
  8. 'leave my name and this message on it and if you actually
  9. 'use it or any portion of it in developing your applications that you
  10. 'just drop me a note on American On-Line: RobertGJR
  11. 'or CompuServe:  75010,754.
  12.  
  13. 'This is just the first and most simple in a series
  14. 'of Visual Basic modules I am preparing for scientific
  15. 'programmers.  If there's anything you'd like to see
  16. 'drop me a note.
  17. '
  18. 'If you're feeling really generous, PLEASE make a
  19. 'small DONATION to any group working to save the
  20. 'tropical rain forests.  My personal favorites are
  21. 'programs educating children in tropical countries
  22. 'about the values of the rainforest.
  23.  
  24. 'Look for additional products
  25. 'from NATURESOFT in the future.
  26.  
  27.  
  28. Function Arccos (X)
  29.     'Calculates the Inverse Cosine of X
  30.     Arccos = Atn(X / Sqr(-X * X + 1)) + 1.5708
  31. End Function
  32.  
  33. Function ArcCosec (X)
  34.     'Calculates the Inverse Cosecant of X
  35.     ArcCosec = Atn(X / Sqr(X * X - 1)) + (Sgn(X) - 1) * 1.5708
  36. End Function
  37.  
  38. Function ArcCotan (X)
  39.     'Calculates the Inverse Cotangent of X
  40.     Arcotan = Atn(X) + 1.5708
  41. End Function
  42.  
  43. Function ArcSec (X)
  44.     'Calculates the Inverse Secant of X
  45.     ArcSec = Atn(X / Sqr(X * X - 1)) + Sgn(Sgn(X) - 1) * 1.5708
  46. End Function
  47.  
  48. Function Arcsin (X)
  49.     'Calculates the Inverse Sine of X
  50.     Arcsin = Atn(X / Sqr(-X * X + 1))
  51. End Function
  52.  
  53. Function Cosec (X)
  54.     'Calculates the Cosecant of X
  55.     Cosec = 1 / Sin(X)
  56. End Function
  57.  
  58. Function Cot (X)
  59.     'Calculates the Cotangent of X
  60.     Cot = 1 / Tan(X)
  61. End Function
  62.  
  63. Function HArccos (X)
  64.     'Calculates the Inverse Hyperbolic Cosine of X
  65.     HArccos = Log(X + Sqr(X * X - 1))
  66. End Function
  67.  
  68. Function HArccosec (X)
  69.     'Calculates the Inverse Hyperbolic Cosecant of X
  70.     HArccosec = Log((Sgn(X) * Sqr(X * X + 1) + 1) / X)
  71. End Function
  72.  
  73. Function HArccotan (X)
  74.     'Calculates the Inverse Hyperbolic Cotangent of X
  75.     HArccotan = Log((X + 1) / (X - 1)) / 2
  76. End Function
  77.  
  78. Function HArcsec (X)
  79.     'Calculates the Inverse Hyperbolic Secant of X
  80.     HArcsec = Log((Sqr(-X * X + 1) + 1) / X)
  81. End Function
  82.  
  83. Function HArcsin (X)
  84.     'Calculates the Inverse Hyperbolic Sine of X
  85.     HArcsin = Log(X + Sqr(X * X + 1))
  86. End Function
  87.  
  88. Function HArctan (X)
  89.     'Calculates the Inverse Hyperbolic Tangent of X
  90.     HArctan = Log((1 + X) / (1 - X)) / 2
  91. End Function
  92.  
  93. Function Hcos (X)
  94.     'Calculates the Hyperbolic Cosine of X
  95.     Hcos = (Exp(X) + Exp(-X)) / 2
  96. End Function
  97.  
  98. Function HCoSec (X)
  99.     'Caluclates the Hyperbolic Cosecant of X
  100.     HCoSec = 2 / (Exp(X) - Exp(-X))
  101. End Function
  102.  
  103. Function HCotan (X)
  104.     'Calculates the Hyperbolic Cotangent of X
  105.     HCotan = (Exp(X) + Exp(-X)) / (Exp(X) - Exp(-X))
  106. End Function
  107.  
  108. Function HSec (X)
  109.     'Calculates the Hyperbolic Secant of X
  110.     HSec = 2 / (Exp(X) + Exp(-X))
  111. End Function
  112.  
  113. Function Hsin (X)
  114.     'Calculates the Hyperbolic Sine of X
  115.     Hsin = (Exp(X) - Exp(-X)) / 2
  116. End Function
  117.  
  118. Function HTan (X)
  119.     'Calculates the Hyperbolic HTan
  120.     HTan = (Exp(X) - Exp(-X)) / (Exp(X) + Exp(-X))
  121. End Function
  122.  
  123. Function LogN (X, N)
  124.     'Calculates the logarithm base N of X
  125.     LogN = Log(X) / Log(N)
  126. End Function
  127.  
  128. Function Sec (X)
  129.     'Calculates the Secant of X
  130.     Sec = 1 / Cos(X)
  131. End Function
  132.  
  133.